package practice.w903;

import java.util.Random;

public class MethodDemo {
    public static void main(String[] args) {
       say();
       say("tcl");
       say("tcl",25);
       sum(20,5);
       generateArray(20,100);
    }
    //定义say()无参无返回值方法，调用测试
    public static void say(){
        System.out.println("Hello World");
    };

     //定义say()有一个参无返回值方法，调用测试
    public static void say(String name){
        System.out.println("Hello "+name);
    }

     // 定义say()有两个参无返回值的方法，调用测试
    public static void say(String name, int age){
        System.out.println("Hello "+name+"今年 "+age);
    }

     //定义sum()两个参有返回值方法，调用测试
    public static int sum(int a, int b){
        return a+b;
    }

    //定义generateArray()用于生成整型数组填充随机数并返回数组，调用测试
    public static int[] generateArray(int length, int max){
        int[] array = new int[length];
        Random random = new Random();
        for(int i=0; i<length; i++){
            array[i] = random.nextInt(max+1);
        }
         return array;
    }

}
